﻿using System;

namespace MyFloridaHouse.libSvOpenDistricts.PDF
{
    public delegate void PDFMapCompleteEventHandler(object sender, PDFMapCompleteEventArgs e);

    public class PDFMapCompleteEventArgs : EventArgs
    {
        public bool IsSuccess { get; set; }
        public PDFMapCompleteEventArgs(bool success)
        {
            this.IsSuccess = success;
        }
    }

    public class PDFdocEvents
    {
        public static event PDFMapCompleteEventHandler PDFMapComplete;

        public static void RaisePDFMapComplete(object sender, bool success)
        {
            if (PDFMapComplete != null)
            {
                PDFMapComplete(sender, new PDFMapCompleteEventArgs(success));
            }
            else
            {
                // todo: Log this error
                //throw (new NotImplementedException("PDFMapComplete Event is null"));
            }
        }


        internal static void UnsubscribePDFMapComplete()
        {
            try
            {
                foreach(var handler in PDFdocEvents.PDFMapComplete.GetInvocationList())
                {
                    PDFMapComplete -= (PDFMapCompleteEventHandler)handler;
                }
            }
            catch { }
        }
    }
}
